import React, { useState } from 'react'
import B from './B';

//1. 创建上下文对象
export let countContext=React.createContext();

export default function A() {
    let [count,setCount]=useState(100);
    
  return (
    <div>
{/* 2. 将后代组件全部包裹在 Provider 组件中   value={count}  */}
        <countContext.Provider value={[count,setCount]}>
            <h1>这是A组件: {count}</h1>
            <B></B>
        </countContext.Provider>
    </div>
  )
}
